package com.example.stock.controller;

import com.example.stock.compone.EmaComponent;
import com.example.stock.service.StockDetailService;
import com.example.stock.service.StockStatService;
import com.example.stock.service.stat.StatService;
import com.example.stock.vo.DataVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
public class MaAnalysisController {
    @Resource
    private StockDetailService stockDetailService;
    @Resource
    private EmaComponent emaComponent;
    @Resource
    private StatService statService;

    @RequestMapping("analysis_file")
    public String analysis() {
        return stockDetailService.analysisFile();
    }

    @RequestMapping("statistics_ma")
    public String statistics_ma() {
        emaComponent.startStatistics();
        List<DataVo> closeData = stockDetailService.getRowData();
        statService.statisticsMa(closeData);
        return "success!";
    }

    @RequestMapping("statistics_ma_cross")
    public String statistics_ma_cross() {
        emaComponent.startStatistics();
        List<DataVo> closeData = stockDetailService.getRowData();
        statService.statisticsMaCross(closeData);
        return "success!";
    }

}
